// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![allow(rustdoc::invalid_html_tags)]
#![allow(rustdoc::bare_urls)]
#![no_implicit_prelude]
extern crate async_trait;
extern crate bytes;
extern crate gax;
extern crate gaxi;
extern crate lazy_static;
extern crate location;
extern crate longrunning;
extern crate lro;
extern crate reqwest;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate tracing;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// Workflow program to be executed by Workflows.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Workflow {
    /// The resource name of the workflow.
    /// Format: projects/{project}/locations/{location}/workflows/{workflow}.
    /// This is a workflow-wide field and is not tied to a specific revision.
    pub name: std::string::String,

    /// Description of the workflow provided by the user.
    /// Must be at most 1000 Unicode characters long.
    /// This is a workflow-wide field and is not tied to a specific revision.
    pub description: std::string::String,

    /// Output only. State of the workflow deployment.
    pub state: crate::model::workflow::State,

    /// Output only. The revision of the workflow.
    /// A new revision of a workflow is created as a result of updating the
    /// following properties of a workflow:
    ///
    /// - [Service account][google.cloud.workflows.v1.Workflow.service_account]
    /// - [Workflow code to be
    ///   executed][google.cloud.workflows.v1.Workflow.source_contents]
    ///
    /// The format is "000001-a4d", where the first six characters define
    /// the zero-padded revision ordinal number. They are followed by a hyphen and
    /// three hexadecimal random characters.
    ///
    /// [google.cloud.workflows.v1.Workflow.service_account]: crate::model::Workflow::service_account
    /// [google.cloud.workflows.v1.Workflow.source_contents]: crate::model::Workflow::source_code
    pub revision_id: std::string::String,

    /// Output only. The timestamp for when the workflow was created.
    /// This is a workflow-wide field and is not tied to a specific revision.
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// Output only. The timestamp for when the workflow was last updated.
    /// This is a workflow-wide field and is not tied to a specific revision.
    pub update_time: std::option::Option<wkt::Timestamp>,

    /// Output only. The timestamp for the latest revision of the workflow's
    /// creation.
    pub revision_create_time: std::option::Option<wkt::Timestamp>,

    /// Labels associated with this workflow.
    /// Labels can contain at most 64 entries. Keys and values can be no longer
    /// than 63 characters and can only contain lowercase letters, numeric
    /// characters, underscores, and dashes. Label keys must start with a letter.
    /// International characters are allowed.
    /// This is a workflow-wide field and is not tied to a specific revision.
    pub labels: std::collections::HashMap<std::string::String, std::string::String>,

    /// The service account associated with the latest workflow version.
    /// This service account represents the identity of the workflow and determines
    /// what permissions the workflow has.
    /// Format: projects/{project}/serviceAccounts/{account} or {account}
    ///
    /// Using `-` as a wildcard for the `{project}` or not providing one at all
    /// will infer the project from the account. The `{account}` value can be the
    /// `email` address or the `unique_id` of the service account.
    ///
    /// If not provided, workflow will use the project's default service account.
    /// Modifying this field for an existing workflow results in a new workflow
    /// revision.
    pub service_account: std::string::String,

    /// Optional. The resource name of a KMS crypto key used to encrypt or decrypt
    /// the data associated with the workflow.
    ///
    /// Format:
    /// projects/{project}/locations/{location}/keyRings/{keyRing}/cryptoKeys/{cryptoKey}
    ///
    /// Using `-` as a wildcard for the `{project}` or not providing one at all
    /// will infer the project from the account.
    ///
    /// If not provided, data associated with the workflow will not be
    /// CMEK-encrypted.
    pub crypto_key_name: std::string::String,

    /// Output only. Error regarding the state of the workflow. For example, this
    /// field will have error details if the execution data is unavailable due to
    /// revoked KMS key permissions.
    pub state_error: std::option::Option<crate::model::workflow::StateError>,

    /// Optional. Describes the level of platform logging to apply to calls and
    /// call responses during executions of this workflow. If both the workflow and
    /// the execution specify a logging level, the execution level takes
    /// precedence.
    pub call_log_level: crate::model::workflow::CallLogLevel,

    /// Optional. User-defined environment variables associated with this workflow
    /// revision. This map has a maximum length of 20. Each string can take up to
    /// 4KiB. Keys cannot be empty strings and cannot start with "GOOGLE" or
    /// "WORKFLOWS".
    pub user_env_vars: std::collections::HashMap<std::string::String, std::string::String>,

    /// Optional. Describes the execution history level to apply to this workflow.
    pub execution_history_level: crate::model::ExecutionHistoryLevel,

    /// Output only. A list of all KMS crypto keys used to encrypt or decrypt the
    /// data associated with the workflow.
    pub all_kms_keys: std::vec::Vec<std::string::String>,

    /// Output only. A list of all KMS crypto key versions used to encrypt or
    /// decrypt the data associated with the workflow.
    pub all_kms_keys_versions: std::vec::Vec<std::string::String>,

    /// Output only. The resource name of a KMS crypto key version used to encrypt
    /// or decrypt the data associated with the workflow.
    ///
    /// Format:
    /// projects/{project}/locations/{location}/keyRings/{keyRing}/cryptoKeys/{cryptoKey}/cryptoKeyVersions/{cryptoKeyVersion}
    pub crypto_key_version: std::string::String,

    /// Optional. Input only. Immutable. Tags associated with this workflow.
    pub tags: std::collections::HashMap<std::string::String, std::string::String>,

    /// Required. Location of the workflow source code.
    /// Modifying this field for an existing workflow results in a new workflow
    /// revision.
    pub source_code: std::option::Option<crate::model::workflow::SourceCode>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Workflow {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::Workflow::name].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::Workflow;
    /// let x = Workflow::new().set_name("example");
    /// ```
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [description][crate::model::Workflow::description].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::Workflow;
    /// let x = Workflow::new().set_description("example");
    /// ```
    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.description = v.into();
        self
    }

    /// Sets the value of [state][crate::model::Workflow::state].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::Workflow;
    /// use google_cloud_workflows_v1::model::workflow::State;
    /// let x0 = Workflow::new().set_state(State::Active);
    /// let x1 = Workflow::new().set_state(State::Unavailable);
    /// ```
    pub fn set_state<T: std::convert::Into<crate::model::workflow::State>>(mut self, v: T) -> Self {
        self.state = v.into();
        self
    }

    /// Sets the value of [revision_id][crate::model::Workflow::revision_id].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::Workflow;
    /// let x = Workflow::new().set_revision_id("example");
    /// ```
    pub fn set_revision_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.revision_id = v.into();
        self
    }

    /// Sets the value of [create_time][crate::model::Workflow::create_time].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::Workflow;
    /// use wkt::Timestamp;
    /// let x = Workflow::new().set_create_time(Timestamp::default()/* use setters */);
    /// ```
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::Workflow::create_time].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::Workflow;
    /// use wkt::Timestamp;
    /// let x = Workflow::new().set_or_clear_create_time(Some(Timestamp::default()/* use setters */));
    /// let x = Workflow::new().set_or_clear_create_time(None::<Timestamp>);
    /// ```
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [update_time][crate::model::Workflow::update_time].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::Workflow;
    /// use wkt::Timestamp;
    /// let x = Workflow::new().set_update_time(Timestamp::default()/* use setters */);
    /// ```
    pub fn set_update_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_time][crate::model::Workflow::update_time].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::Workflow;
    /// use wkt::Timestamp;
    /// let x = Workflow::new().set_or_clear_update_time(Some(Timestamp::default()/* use setters */));
    /// let x = Workflow::new().set_or_clear_update_time(None::<Timestamp>);
    /// ```
    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [revision_create_time][crate::model::Workflow::revision_create_time].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::Workflow;
    /// use wkt::Timestamp;
    /// let x = Workflow::new().set_revision_create_time(Timestamp::default()/* use setters */);
    /// ```
    pub fn set_revision_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.revision_create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [revision_create_time][crate::model::Workflow::revision_create_time].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::Workflow;
    /// use wkt::Timestamp;
    /// let x = Workflow::new().set_or_clear_revision_create_time(Some(Timestamp::default()/* use setters */));
    /// let x = Workflow::new().set_or_clear_revision_create_time(None::<Timestamp>);
    /// ```
    pub fn set_or_clear_revision_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.revision_create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [labels][crate::model::Workflow::labels].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::Workflow;
    /// let x = Workflow::new().set_labels([
    ///     ("key0", "abc"),
    ///     ("key1", "xyz"),
    /// ]);
    /// ```
    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }

    /// Sets the value of [service_account][crate::model::Workflow::service_account].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::Workflow;
    /// let x = Workflow::new().set_service_account("example");
    /// ```
    pub fn set_service_account<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.service_account = v.into();
        self
    }

    /// Sets the value of [crypto_key_name][crate::model::Workflow::crypto_key_name].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::Workflow;
    /// let x = Workflow::new().set_crypto_key_name("example");
    /// ```
    pub fn set_crypto_key_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.crypto_key_name = v.into();
        self
    }

    /// Sets the value of [state_error][crate::model::Workflow::state_error].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::Workflow;
    /// use google_cloud_workflows_v1::model::workflow::StateError;
    /// let x = Workflow::new().set_state_error(StateError::default()/* use setters */);
    /// ```
    pub fn set_state_error<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::workflow::StateError>,
    {
        self.state_error = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [state_error][crate::model::Workflow::state_error].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::Workflow;
    /// use google_cloud_workflows_v1::model::workflow::StateError;
    /// let x = Workflow::new().set_or_clear_state_error(Some(StateError::default()/* use setters */));
    /// let x = Workflow::new().set_or_clear_state_error(None::<StateError>);
    /// ```
    pub fn set_or_clear_state_error<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::workflow::StateError>,
    {
        self.state_error = v.map(|x| x.into());
        self
    }

    /// Sets the value of [call_log_level][crate::model::Workflow::call_log_level].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::Workflow;
    /// use google_cloud_workflows_v1::model::workflow::CallLogLevel;
    /// let x0 = Workflow::new().set_call_log_level(CallLogLevel::LogAllCalls);
    /// let x1 = Workflow::new().set_call_log_level(CallLogLevel::LogErrorsOnly);
    /// let x2 = Workflow::new().set_call_log_level(CallLogLevel::LogNone);
    /// ```
    pub fn set_call_log_level<T: std::convert::Into<crate::model::workflow::CallLogLevel>>(
        mut self,
        v: T,
    ) -> Self {
        self.call_log_level = v.into();
        self
    }

    /// Sets the value of [user_env_vars][crate::model::Workflow::user_env_vars].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::Workflow;
    /// let x = Workflow::new().set_user_env_vars([
    ///     ("key0", "abc"),
    ///     ("key1", "xyz"),
    /// ]);
    /// ```
    pub fn set_user_env_vars<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.user_env_vars = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }

    /// Sets the value of [execution_history_level][crate::model::Workflow::execution_history_level].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::Workflow;
    /// use google_cloud_workflows_v1::model::ExecutionHistoryLevel;
    /// let x0 = Workflow::new().set_execution_history_level(ExecutionHistoryLevel::ExecutionHistoryBasic);
    /// let x1 = Workflow::new().set_execution_history_level(ExecutionHistoryLevel::ExecutionHistoryDetailed);
    /// ```
    pub fn set_execution_history_level<
        T: std::convert::Into<crate::model::ExecutionHistoryLevel>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.execution_history_level = v.into();
        self
    }

    /// Sets the value of [all_kms_keys][crate::model::Workflow::all_kms_keys].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::Workflow;
    /// let x = Workflow::new().set_all_kms_keys(["a", "b", "c"]);
    /// ```
    pub fn set_all_kms_keys<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.all_kms_keys = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [all_kms_keys_versions][crate::model::Workflow::all_kms_keys_versions].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::Workflow;
    /// let x = Workflow::new().set_all_kms_keys_versions(["a", "b", "c"]);
    /// ```
    pub fn set_all_kms_keys_versions<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.all_kms_keys_versions = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [crypto_key_version][crate::model::Workflow::crypto_key_version].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::Workflow;
    /// let x = Workflow::new().set_crypto_key_version("example");
    /// ```
    pub fn set_crypto_key_version<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.crypto_key_version = v.into();
        self
    }

    /// Sets the value of [tags][crate::model::Workflow::tags].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::Workflow;
    /// let x = Workflow::new().set_tags([
    ///     ("key0", "abc"),
    ///     ("key1", "xyz"),
    /// ]);
    /// ```
    pub fn set_tags<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.tags = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }

    /// Sets the value of [source_code][crate::model::Workflow::source_code].
    ///
    /// Note that all the setters affecting `source_code` are mutually
    /// exclusive.
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::Workflow;
    /// use google_cloud_workflows_v1::model::workflow;
    /// let x = Workflow::new().set_source_code(Some(workflow::SourceCode::SourceContents("example".to_string())));
    /// ```
    pub fn set_source_code<
        T: std::convert::Into<std::option::Option<crate::model::workflow::SourceCode>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.source_code = v.into();
        self
    }

    /// The value of [source_code][crate::model::Workflow::source_code]
    /// if it holds a `SourceContents`, `None` if the field is not set or
    /// holds a different branch.
    pub fn source_contents(&self) -> std::option::Option<&std::string::String> {
        #[allow(unreachable_patterns)]
        self.source_code.as_ref().and_then(|v| match v {
            crate::model::workflow::SourceCode::SourceContents(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [source_code][crate::model::Workflow::source_code]
    /// to hold a `SourceContents`.
    ///
    /// Note that all the setters affecting `source_code` are
    /// mutually exclusive.
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::Workflow;
    /// let x = Workflow::new().set_source_contents("example");
    /// assert!(x.source_contents().is_some());
    /// ```
    pub fn set_source_contents<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.source_code =
            std::option::Option::Some(crate::model::workflow::SourceCode::SourceContents(v.into()));
        self
    }
}

impl wkt::message::Message for Workflow {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.workflows.v1.Workflow"
    }
}

/// Defines additional types related to [Workflow].
pub mod workflow {
    #[allow(unused_imports)]
    use super::*;

    /// Describes an error related to the current state of the workflow.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct StateError {
        /// Provides specifics about the error.
        pub details: std::string::String,

        /// The type of this state error.
        pub r#type: crate::model::workflow::state_error::Type,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl StateError {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [details][crate::model::workflow::StateError::details].
        ///
        /// # Example
        /// ```
        /// # use google_cloud_workflows_v1::model::workflow::StateError;
        /// let x = StateError::new().set_details("example");
        /// ```
        pub fn set_details<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
            self.details = v.into();
            self
        }

        /// Sets the value of [r#type][crate::model::workflow::StateError::type].
        ///
        /// # Example
        /// ```
        /// # use google_cloud_workflows_v1::model::workflow::StateError;
        /// use google_cloud_workflows_v1::model::workflow::state_error::Type;
        /// let x0 = StateError::new().set_type(Type::KmsError);
        /// ```
        pub fn set_type<T: std::convert::Into<crate::model::workflow::state_error::Type>>(
            mut self,
            v: T,
        ) -> Self {
            self.r#type = v.into();
            self
        }
    }

    impl wkt::message::Message for StateError {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.workflows.v1.Workflow.StateError"
        }
    }

    /// Defines additional types related to [StateError].
    pub mod state_error {
        #[allow(unused_imports)]
        use super::*;

        /// Describes the possibled types of a state error.
        ///
        /// # Working with unknown values
        ///
        /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
        /// additional enum variants at any time. Adding new variants is not considered
        /// a breaking change. Applications should write their code in anticipation of:
        ///
        /// - New values appearing in future releases of the client library, **and**
        /// - New values received dynamically, without application changes.
        ///
        /// Please consult the [Working with enums] section in the user guide for some
        /// guidelines.
        ///
        /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
        #[derive(Clone, Debug, PartialEq)]
        #[non_exhaustive]
        pub enum Type {
            /// No type specified.
            Unspecified,
            /// Caused by an issue with KMS.
            KmsError,
            /// If set, the enum was initialized with an unknown value.
            ///
            /// Applications can examine the value using [Type::value] or
            /// [Type::name].
            UnknownValue(r#type::UnknownValue),
        }

        #[doc(hidden)]
        pub mod r#type {
            #[allow(unused_imports)]
            use super::*;
            #[derive(Clone, Debug, PartialEq)]
            pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
        }

        impl Type {
            /// Gets the enum value.
            ///
            /// Returns `None` if the enum contains an unknown value deserialized from
            /// the string representation of enums.
            pub fn value(&self) -> std::option::Option<i32> {
                match self {
                    Self::Unspecified => std::option::Option::Some(0),
                    Self::KmsError => std::option::Option::Some(1),
                    Self::UnknownValue(u) => u.0.value(),
                }
            }

            /// Gets the enum value as a string.
            ///
            /// Returns `None` if the enum contains an unknown value deserialized from
            /// the integer representation of enums.
            pub fn name(&self) -> std::option::Option<&str> {
                match self {
                    Self::Unspecified => std::option::Option::Some("TYPE_UNSPECIFIED"),
                    Self::KmsError => std::option::Option::Some("KMS_ERROR"),
                    Self::UnknownValue(u) => u.0.name(),
                }
            }
        }

        impl std::default::Default for Type {
            fn default() -> Self {
                use std::convert::From;
                Self::from(0)
            }
        }

        impl std::fmt::Display for Type {
            fn fmt(
                &self,
                f: &mut std::fmt::Formatter<'_>,
            ) -> std::result::Result<(), std::fmt::Error> {
                wkt::internal::display_enum(f, self.name(), self.value())
            }
        }

        impl std::convert::From<i32> for Type {
            fn from(value: i32) -> Self {
                match value {
                    0 => Self::Unspecified,
                    1 => Self::KmsError,
                    _ => Self::UnknownValue(r#type::UnknownValue(
                        wkt::internal::UnknownEnumValue::Integer(value),
                    )),
                }
            }
        }

        impl std::convert::From<&str> for Type {
            fn from(value: &str) -> Self {
                use std::string::ToString;
                match value {
                    "TYPE_UNSPECIFIED" => Self::Unspecified,
                    "KMS_ERROR" => Self::KmsError,
                    _ => Self::UnknownValue(r#type::UnknownValue(
                        wkt::internal::UnknownEnumValue::String(value.to_string()),
                    )),
                }
            }
        }

        impl serde::ser::Serialize for Type {
            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
            where
                S: serde::Serializer,
            {
                match self {
                    Self::Unspecified => serializer.serialize_i32(0),
                    Self::KmsError => serializer.serialize_i32(1),
                    Self::UnknownValue(u) => u.0.serialize(serializer),
                }
            }
        }

        impl<'de> serde::de::Deserialize<'de> for Type {
            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
            where
                D: serde::Deserializer<'de>,
            {
                deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
                    ".google.cloud.workflows.v1.Workflow.StateError.Type",
                ))
            }
        }
    }

    /// Describes the current state of workflow deployment.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum State {
        /// Invalid state.
        Unspecified,
        /// The workflow has been deployed successfully and is serving.
        Active,
        /// Workflow data is unavailable. See the `state_error` field.
        Unavailable,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [State::value] or
        /// [State::name].
        UnknownValue(state::UnknownValue),
    }

    #[doc(hidden)]
    pub mod state {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl State {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Active => std::option::Option::Some(1),
                Self::Unavailable => std::option::Option::Some(2),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
                Self::Active => std::option::Option::Some("ACTIVE"),
                Self::Unavailable => std::option::Option::Some("UNAVAILABLE"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for State {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for State {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for State {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Active,
                2 => Self::Unavailable,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for State {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "STATE_UNSPECIFIED" => Self::Unspecified,
                "ACTIVE" => Self::Active,
                "UNAVAILABLE" => Self::Unavailable,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for State {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Active => serializer.serialize_i32(1),
                Self::Unavailable => serializer.serialize_i32(2),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for State {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
                ".google.cloud.workflows.v1.Workflow.State",
            ))
        }
    }

    /// Describes the level of platform logging to apply to calls and call
    /// responses during workflow executions.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum CallLogLevel {
        /// No call logging level specified.
        Unspecified,
        /// Log all call steps within workflows, all call returns, and all exceptions
        /// raised.
        LogAllCalls,
        /// Log only exceptions that are raised from call steps within workflows.
        LogErrorsOnly,
        /// Explicitly log nothing.
        LogNone,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [CallLogLevel::value] or
        /// [CallLogLevel::name].
        UnknownValue(call_log_level::UnknownValue),
    }

    #[doc(hidden)]
    pub mod call_log_level {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl CallLogLevel {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::LogAllCalls => std::option::Option::Some(1),
                Self::LogErrorsOnly => std::option::Option::Some(2),
                Self::LogNone => std::option::Option::Some(3),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("CALL_LOG_LEVEL_UNSPECIFIED"),
                Self::LogAllCalls => std::option::Option::Some("LOG_ALL_CALLS"),
                Self::LogErrorsOnly => std::option::Option::Some("LOG_ERRORS_ONLY"),
                Self::LogNone => std::option::Option::Some("LOG_NONE"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for CallLogLevel {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for CallLogLevel {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for CallLogLevel {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::LogAllCalls,
                2 => Self::LogErrorsOnly,
                3 => Self::LogNone,
                _ => Self::UnknownValue(call_log_level::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for CallLogLevel {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "CALL_LOG_LEVEL_UNSPECIFIED" => Self::Unspecified,
                "LOG_ALL_CALLS" => Self::LogAllCalls,
                "LOG_ERRORS_ONLY" => Self::LogErrorsOnly,
                "LOG_NONE" => Self::LogNone,
                _ => Self::UnknownValue(call_log_level::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for CallLogLevel {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::LogAllCalls => serializer.serialize_i32(1),
                Self::LogErrorsOnly => serializer.serialize_i32(2),
                Self::LogNone => serializer.serialize_i32(3),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for CallLogLevel {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<CallLogLevel>::new(
                ".google.cloud.workflows.v1.Workflow.CallLogLevel",
            ))
        }
    }

    /// Required. Location of the workflow source code.
    /// Modifying this field for an existing workflow results in a new workflow
    /// revision.
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum SourceCode {
        /// Workflow code to be executed. The size limit is 128KB.
        SourceContents(std::string::String),
    }
}

/// Request for the
/// [ListWorkflows][google.cloud.workflows.v1.Workflows.ListWorkflows]
/// method.
///
/// [google.cloud.workflows.v1.Workflows.ListWorkflows]: crate::client::Workflows::list_workflows
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListWorkflowsRequest {
    /// Required. Project and location from which the workflows should be listed.
    /// Format: projects/{project}/locations/{location}
    pub parent: std::string::String,

    /// Maximum number of workflows to return per call. The service might return
    /// fewer than this value even if not at the end of the collection. If a value
    /// is not specified, a default value of 500 is used. The maximum permitted
    /// value is 1000 and values greater than 1000 are coerced down to 1000.
    pub page_size: i32,

    /// A page token, received from a previous `ListWorkflows` call.
    /// Provide this to retrieve the subsequent page.
    ///
    /// When paginating, all other parameters provided to `ListWorkflows` must
    /// match the call that provided the page token.
    pub page_token: std::string::String,

    /// Filter to restrict results to specific workflows.
    /// For details, see <a href="https://google.aip.dev/160"
    /// class="external"\>AIP-160</a>.
    ///
    /// For example, if you are using the Google APIs Explorer:
    ///
    /// `state="SUCCEEDED"`
    ///
    /// or
    ///
    /// `createTime>"2023-08-01" AND state="FAILED"`
    pub filter: std::string::String,

    /// Comma-separated list of fields that specify the order of the results.
    /// Default sorting order for a field is ascending. To specify descending order
    /// for a field, append a "desc" suffix.
    /// If not specified, the results are returned in an unspecified order.
    pub order_by: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListWorkflowsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListWorkflowsRequest::parent].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::ListWorkflowsRequest;
    /// let x = ListWorkflowsRequest::new().set_parent("example");
    /// ```
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListWorkflowsRequest::page_size].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::ListWorkflowsRequest;
    /// let x = ListWorkflowsRequest::new().set_page_size(42);
    /// ```
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListWorkflowsRequest::page_token].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::ListWorkflowsRequest;
    /// let x = ListWorkflowsRequest::new().set_page_token("example");
    /// ```
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }

    /// Sets the value of [filter][crate::model::ListWorkflowsRequest::filter].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::ListWorkflowsRequest;
    /// let x = ListWorkflowsRequest::new().set_filter("example");
    /// ```
    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.filter = v.into();
        self
    }

    /// Sets the value of [order_by][crate::model::ListWorkflowsRequest::order_by].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::ListWorkflowsRequest;
    /// let x = ListWorkflowsRequest::new().set_order_by("example");
    /// ```
    pub fn set_order_by<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.order_by = v.into();
        self
    }
}

impl wkt::message::Message for ListWorkflowsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.workflows.v1.ListWorkflowsRequest"
    }
}

/// Response for the
/// [ListWorkflows][google.cloud.workflows.v1.Workflows.ListWorkflows]
/// method.
///
/// [google.cloud.workflows.v1.Workflows.ListWorkflows]: crate::client::Workflows::list_workflows
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListWorkflowsResponse {
    /// The workflows that match the request.
    pub workflows: std::vec::Vec<crate::model::Workflow>,

    /// A token, which can be sent as `page_token` to retrieve the next page.
    /// If this field is omitted, there are no subsequent pages.
    pub next_page_token: std::string::String,

    /// Unreachable resources.
    pub unreachable: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListWorkflowsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [workflows][crate::model::ListWorkflowsResponse::workflows].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::ListWorkflowsResponse;
    /// use google_cloud_workflows_v1::model::Workflow;
    /// let x = ListWorkflowsResponse::new()
    ///     .set_workflows([
    ///         Workflow::default()/* use setters */,
    ///         Workflow::default()/* use (different) setters */,
    ///     ]);
    /// ```
    pub fn set_workflows<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::Workflow>,
    {
        use std::iter::Iterator;
        self.workflows = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListWorkflowsResponse::next_page_token].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::ListWorkflowsResponse;
    /// let x = ListWorkflowsResponse::new().set_next_page_token("example");
    /// ```
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }

    /// Sets the value of [unreachable][crate::model::ListWorkflowsResponse::unreachable].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::ListWorkflowsResponse;
    /// let x = ListWorkflowsResponse::new().set_unreachable(["a", "b", "c"]);
    /// ```
    pub fn set_unreachable<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.unreachable = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ListWorkflowsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.workflows.v1.ListWorkflowsResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListWorkflowsResponse {
    type PageItem = crate::model::Workflow;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.workflows
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// Request for the
/// [GetWorkflow][google.cloud.workflows.v1.Workflows.GetWorkflow] method.
///
/// [google.cloud.workflows.v1.Workflows.GetWorkflow]: crate::client::Workflows::get_workflow
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetWorkflowRequest {
    /// Required. Name of the workflow for which information should be retrieved.
    /// Format: projects/{project}/locations/{location}/workflows/{workflow}
    pub name: std::string::String,

    /// Optional. The revision of the workflow to retrieve. If the revision_id is
    /// empty, the latest revision is retrieved.
    /// The format is "000001-a4d", where the first six characters define
    /// the zero-padded decimal revision number. They are followed by a hyphen and
    /// three hexadecimal characters.
    pub revision_id: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetWorkflowRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetWorkflowRequest::name].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::GetWorkflowRequest;
    /// let x = GetWorkflowRequest::new().set_name("example");
    /// ```
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [revision_id][crate::model::GetWorkflowRequest::revision_id].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::GetWorkflowRequest;
    /// let x = GetWorkflowRequest::new().set_revision_id("example");
    /// ```
    pub fn set_revision_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.revision_id = v.into();
        self
    }
}

impl wkt::message::Message for GetWorkflowRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.workflows.v1.GetWorkflowRequest"
    }
}

/// Request for the
/// [CreateWorkflow][google.cloud.workflows.v1.Workflows.CreateWorkflow]
/// method.
///
/// [google.cloud.workflows.v1.Workflows.CreateWorkflow]: crate::client::Workflows::create_workflow
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreateWorkflowRequest {
    /// Required. Project and location in which the workflow should be created.
    /// Format:  projects/{project}/locations/{location}
    pub parent: std::string::String,

    /// Required. Workflow to be created.
    pub workflow: std::option::Option<crate::model::Workflow>,

    /// Required. The ID of the workflow to be created. It has to fulfill the
    /// following requirements:
    ///
    /// * Must contain only letters, numbers, underscores and hyphens.
    /// * Must start with a letter.
    /// * Must be between 1-64 characters.
    /// * Must end with a number or a letter.
    /// * Must be unique within the customer project and location.
    pub workflow_id: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreateWorkflowRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::CreateWorkflowRequest::parent].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::CreateWorkflowRequest;
    /// let x = CreateWorkflowRequest::new().set_parent("example");
    /// ```
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [workflow][crate::model::CreateWorkflowRequest::workflow].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::CreateWorkflowRequest;
    /// use google_cloud_workflows_v1::model::Workflow;
    /// let x = CreateWorkflowRequest::new().set_workflow(Workflow::default()/* use setters */);
    /// ```
    pub fn set_workflow<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Workflow>,
    {
        self.workflow = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [workflow][crate::model::CreateWorkflowRequest::workflow].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::CreateWorkflowRequest;
    /// use google_cloud_workflows_v1::model::Workflow;
    /// let x = CreateWorkflowRequest::new().set_or_clear_workflow(Some(Workflow::default()/* use setters */));
    /// let x = CreateWorkflowRequest::new().set_or_clear_workflow(None::<Workflow>);
    /// ```
    pub fn set_or_clear_workflow<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Workflow>,
    {
        self.workflow = v.map(|x| x.into());
        self
    }

    /// Sets the value of [workflow_id][crate::model::CreateWorkflowRequest::workflow_id].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::CreateWorkflowRequest;
    /// let x = CreateWorkflowRequest::new().set_workflow_id("example");
    /// ```
    pub fn set_workflow_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.workflow_id = v.into();
        self
    }
}

impl wkt::message::Message for CreateWorkflowRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.workflows.v1.CreateWorkflowRequest"
    }
}

/// Request for the
/// [DeleteWorkflow][google.cloud.workflows.v1.Workflows.DeleteWorkflow]
/// method.
///
/// [google.cloud.workflows.v1.Workflows.DeleteWorkflow]: crate::client::Workflows::delete_workflow
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DeleteWorkflowRequest {
    /// Required. Name of the workflow to be deleted.
    /// Format: projects/{project}/locations/{location}/workflows/{workflow}
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DeleteWorkflowRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::DeleteWorkflowRequest::name].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::DeleteWorkflowRequest;
    /// let x = DeleteWorkflowRequest::new().set_name("example");
    /// ```
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for DeleteWorkflowRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.workflows.v1.DeleteWorkflowRequest"
    }
}

/// Request for the
/// [UpdateWorkflow][google.cloud.workflows.v1.Workflows.UpdateWorkflow]
/// method.
///
/// [google.cloud.workflows.v1.Workflows.UpdateWorkflow]: crate::client::Workflows::update_workflow
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct UpdateWorkflowRequest {
    /// Required. Workflow to be updated.
    pub workflow: std::option::Option<crate::model::Workflow>,

    /// List of fields to be updated. If not present, the entire workflow
    /// will be updated.
    pub update_mask: std::option::Option<wkt::FieldMask>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl UpdateWorkflowRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [workflow][crate::model::UpdateWorkflowRequest::workflow].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::UpdateWorkflowRequest;
    /// use google_cloud_workflows_v1::model::Workflow;
    /// let x = UpdateWorkflowRequest::new().set_workflow(Workflow::default()/* use setters */);
    /// ```
    pub fn set_workflow<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Workflow>,
    {
        self.workflow = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [workflow][crate::model::UpdateWorkflowRequest::workflow].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::UpdateWorkflowRequest;
    /// use google_cloud_workflows_v1::model::Workflow;
    /// let x = UpdateWorkflowRequest::new().set_or_clear_workflow(Some(Workflow::default()/* use setters */));
    /// let x = UpdateWorkflowRequest::new().set_or_clear_workflow(None::<Workflow>);
    /// ```
    pub fn set_or_clear_workflow<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Workflow>,
    {
        self.workflow = v.map(|x| x.into());
        self
    }

    /// Sets the value of [update_mask][crate::model::UpdateWorkflowRequest::update_mask].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::UpdateWorkflowRequest;
    /// use wkt::FieldMask;
    /// let x = UpdateWorkflowRequest::new().set_update_mask(FieldMask::default()/* use setters */);
    /// ```
    pub fn set_update_mask<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_mask][crate::model::UpdateWorkflowRequest::update_mask].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::UpdateWorkflowRequest;
    /// use wkt::FieldMask;
    /// let x = UpdateWorkflowRequest::new().set_or_clear_update_mask(Some(FieldMask::default()/* use setters */));
    /// let x = UpdateWorkflowRequest::new().set_or_clear_update_mask(None::<FieldMask>);
    /// ```
    pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for UpdateWorkflowRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.workflows.v1.UpdateWorkflowRequest"
    }
}

/// Represents the metadata of the long-running operation.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct OperationMetadata {
    /// The time the operation was created.
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// The time the operation finished running.
    pub end_time: std::option::Option<wkt::Timestamp>,

    /// Server-defined resource path for the target of the operation.
    pub target: std::string::String,

    /// Name of the verb executed by the operation.
    pub verb: std::string::String,

    /// API version used to start the operation.
    pub api_version: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl OperationMetadata {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [create_time][crate::model::OperationMetadata::create_time].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::OperationMetadata;
    /// use wkt::Timestamp;
    /// let x = OperationMetadata::new().set_create_time(Timestamp::default()/* use setters */);
    /// ```
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::OperationMetadata::create_time].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::OperationMetadata;
    /// use wkt::Timestamp;
    /// let x = OperationMetadata::new().set_or_clear_create_time(Some(Timestamp::default()/* use setters */));
    /// let x = OperationMetadata::new().set_or_clear_create_time(None::<Timestamp>);
    /// ```
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [end_time][crate::model::OperationMetadata::end_time].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::OperationMetadata;
    /// use wkt::Timestamp;
    /// let x = OperationMetadata::new().set_end_time(Timestamp::default()/* use setters */);
    /// ```
    pub fn set_end_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [end_time][crate::model::OperationMetadata::end_time].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::OperationMetadata;
    /// use wkt::Timestamp;
    /// let x = OperationMetadata::new().set_or_clear_end_time(Some(Timestamp::default()/* use setters */));
    /// let x = OperationMetadata::new().set_or_clear_end_time(None::<Timestamp>);
    /// ```
    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [target][crate::model::OperationMetadata::target].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::OperationMetadata;
    /// let x = OperationMetadata::new().set_target("example");
    /// ```
    pub fn set_target<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.target = v.into();
        self
    }

    /// Sets the value of [verb][crate::model::OperationMetadata::verb].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::OperationMetadata;
    /// let x = OperationMetadata::new().set_verb("example");
    /// ```
    pub fn set_verb<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.verb = v.into();
        self
    }

    /// Sets the value of [api_version][crate::model::OperationMetadata::api_version].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::OperationMetadata;
    /// let x = OperationMetadata::new().set_api_version("example");
    /// ```
    pub fn set_api_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.api_version = v.into();
        self
    }
}

impl wkt::message::Message for OperationMetadata {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.workflows.v1.OperationMetadata"
    }
}

/// Request for the
/// [ListWorkflowRevisions][google.cloud.workflows.v1.Workflows.ListWorkflowRevisions]
/// method.
///
/// [google.cloud.workflows.v1.Workflows.ListWorkflowRevisions]: crate::client::Workflows::list_workflow_revisions
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListWorkflowRevisionsRequest {
    /// Required. Workflow for which the revisions should be listed.
    /// Format: projects/{project}/locations/{location}/workflows/{workflow}
    pub name: std::string::String,

    /// The maximum number of revisions to return per page. If a value is not
    /// specified, a default value of 20 is used. The maximum permitted value is
    /// 100. Values greater than 100 are coerced down to 100.
    pub page_size: i32,

    /// The page token, received from a previous ListWorkflowRevisions call.
    /// Provide this to retrieve the subsequent page.
    pub page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListWorkflowRevisionsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::ListWorkflowRevisionsRequest::name].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::ListWorkflowRevisionsRequest;
    /// let x = ListWorkflowRevisionsRequest::new().set_name("example");
    /// ```
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListWorkflowRevisionsRequest::page_size].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::ListWorkflowRevisionsRequest;
    /// let x = ListWorkflowRevisionsRequest::new().set_page_size(42);
    /// ```
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListWorkflowRevisionsRequest::page_token].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::ListWorkflowRevisionsRequest;
    /// let x = ListWorkflowRevisionsRequest::new().set_page_token("example");
    /// ```
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListWorkflowRevisionsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.workflows.v1.ListWorkflowRevisionsRequest"
    }
}

/// Response for the
/// [ListWorkflowRevisions][google.cloud.workflows.v1.Workflows.ListWorkflowRevisions]
/// method.
///
/// [google.cloud.workflows.v1.Workflows.ListWorkflowRevisions]: crate::client::Workflows::list_workflow_revisions
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListWorkflowRevisionsResponse {
    /// The revisions of the workflow, ordered in reverse chronological order.
    pub workflows: std::vec::Vec<crate::model::Workflow>,

    /// A token, which can be sent as `page_token` to retrieve the next page.
    /// If this field is omitted, there are no subsequent pages.
    pub next_page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListWorkflowRevisionsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [workflows][crate::model::ListWorkflowRevisionsResponse::workflows].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::ListWorkflowRevisionsResponse;
    /// use google_cloud_workflows_v1::model::Workflow;
    /// let x = ListWorkflowRevisionsResponse::new()
    ///     .set_workflows([
    ///         Workflow::default()/* use setters */,
    ///         Workflow::default()/* use (different) setters */,
    ///     ]);
    /// ```
    pub fn set_workflows<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::Workflow>,
    {
        use std::iter::Iterator;
        self.workflows = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListWorkflowRevisionsResponse::next_page_token].
    ///
    /// # Example
    /// ```
    /// # use google_cloud_workflows_v1::model::ListWorkflowRevisionsResponse;
    /// let x = ListWorkflowRevisionsResponse::new().set_next_page_token("example");
    /// ```
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListWorkflowRevisionsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.workflows.v1.ListWorkflowRevisionsResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListWorkflowRevisionsResponse {
    type PageItem = crate::model::Workflow;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.workflows
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// Define possible options for enabling the execution history level.
///
/// # Working with unknown values
///
/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
/// additional enum variants at any time. Adding new variants is not considered
/// a breaking change. Applications should write their code in anticipation of:
///
/// - New values appearing in future releases of the client library, **and**
/// - New values received dynamically, without application changes.
///
/// Please consult the [Working with enums] section in the user guide for some
/// guidelines.
///
/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum ExecutionHistoryLevel {
    /// The default/unset value.
    Unspecified,
    /// Enable execution history basic feature.
    ExecutionHistoryBasic,
    /// Enable execution history detailed feature.
    ExecutionHistoryDetailed,
    /// If set, the enum was initialized with an unknown value.
    ///
    /// Applications can examine the value using [ExecutionHistoryLevel::value] or
    /// [ExecutionHistoryLevel::name].
    UnknownValue(execution_history_level::UnknownValue),
}

#[doc(hidden)]
pub mod execution_history_level {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Clone, Debug, PartialEq)]
    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}

impl ExecutionHistoryLevel {
    /// Gets the enum value.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the string representation of enums.
    pub fn value(&self) -> std::option::Option<i32> {
        match self {
            Self::Unspecified => std::option::Option::Some(0),
            Self::ExecutionHistoryBasic => std::option::Option::Some(1),
            Self::ExecutionHistoryDetailed => std::option::Option::Some(2),
            Self::UnknownValue(u) => u.0.value(),
        }
    }

    /// Gets the enum value as a string.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the integer representation of enums.
    pub fn name(&self) -> std::option::Option<&str> {
        match self {
            Self::Unspecified => std::option::Option::Some("EXECUTION_HISTORY_LEVEL_UNSPECIFIED"),
            Self::ExecutionHistoryBasic => std::option::Option::Some("EXECUTION_HISTORY_BASIC"),
            Self::ExecutionHistoryDetailed => {
                std::option::Option::Some("EXECUTION_HISTORY_DETAILED")
            }
            Self::UnknownValue(u) => u.0.name(),
        }
    }
}

impl std::default::Default for ExecutionHistoryLevel {
    fn default() -> Self {
        use std::convert::From;
        Self::from(0)
    }
}

impl std::fmt::Display for ExecutionHistoryLevel {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        wkt::internal::display_enum(f, self.name(), self.value())
    }
}

impl std::convert::From<i32> for ExecutionHistoryLevel {
    fn from(value: i32) -> Self {
        match value {
            0 => Self::Unspecified,
            1 => Self::ExecutionHistoryBasic,
            2 => Self::ExecutionHistoryDetailed,
            _ => Self::UnknownValue(execution_history_level::UnknownValue(
                wkt::internal::UnknownEnumValue::Integer(value),
            )),
        }
    }
}

impl std::convert::From<&str> for ExecutionHistoryLevel {
    fn from(value: &str) -> Self {
        use std::string::ToString;
        match value {
            "EXECUTION_HISTORY_LEVEL_UNSPECIFIED" => Self::Unspecified,
            "EXECUTION_HISTORY_BASIC" => Self::ExecutionHistoryBasic,
            "EXECUTION_HISTORY_DETAILED" => Self::ExecutionHistoryDetailed,
            _ => Self::UnknownValue(execution_history_level::UnknownValue(
                wkt::internal::UnknownEnumValue::String(value.to_string()),
            )),
        }
    }
}

impl serde::ser::Serialize for ExecutionHistoryLevel {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            Self::Unspecified => serializer.serialize_i32(0),
            Self::ExecutionHistoryBasic => serializer.serialize_i32(1),
            Self::ExecutionHistoryDetailed => serializer.serialize_i32(2),
            Self::UnknownValue(u) => u.0.serialize(serializer),
        }
    }
}

impl<'de> serde::de::Deserialize<'de> for ExecutionHistoryLevel {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_any(wkt::internal::EnumVisitor::<ExecutionHistoryLevel>::new(
            ".google.cloud.workflows.v1.ExecutionHistoryLevel",
        ))
    }
}
